#include <cstdio>
#include <cmath>

int main(int argc, char* argv[]){
  int i,N;
  double sum = 0,tmp1 = 1,tmp2 = 2;
  double x;
  scanf("%lf %d",&x,&N);
  if (N < 1)
    printf("Error! Number of items must be positive integer.\n");
  else if (x <= -1 || x >= 1)
    printf("Error! x does not belong to the domain or will not converge.\n");
  else{
    sum += x;
    for (i = 1 ; i < N ; i++){
      sum += (tmp1*1.0/tmp2)*(pow(x,2*i+1)/(2*i+1));
      tmp1 *= (2*i-1);
      tmp2 *= (2*i);
  }
  printf("When %d items given, result = %f\n",N,sum);
  printf("absolute Error = %f\n",fabs(sum-asin(x)));
  }
}
